package com.woniu.controller;

import com.woniu.pojo.Video;
import com.woniu.service.IVideoService;
import com.woniu.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author xiaoruan
 * @since 2023-03-15
 */
@RestController
@RequestMapping("/video")
public class VideoController extends BaseController{
    @Autowired
    IVideoService videoService;

    @ApiOperation("根据id删除")
    @DeleteMapping("/delete/{id}")
    public Result deleteVideo(@PathVariable String id) {

        videoService.removeById(id);

        return success();
    }


    @ApiOperation("新增或者修改")
    @PostMapping()
    public Result addChapter(@RequestBody Video video) {

        videoService.saveOrUpdate(video);

        return success();

    }

    @ApiOperation("根据id查询")
    @GetMapping("/get/{id}")
    public Result getChapterById(@PathVariable String id) {
        Video video = videoService.getById(id);

        return toDataResult(video);
    }





}
